#include<iostream>
#include<arbb.hpp>
#include<stdio.h>
#include<cstdlib>
#include<sys/time.h>
using namespace arbb;

void Dot_Product( dense<f32> src1,dense<f32> src2,f32 &dst)
{
  dst=add_reduce(src1 * src2);
}

int main()
{
  int N=1000000,i;
  unsigned int n=1000000;
  float A[N],B[N];
  for(i=0;i<N;i++)
    {
      A[i]=i*.00001;
      B[i]=i*.00001;
    }
  dense<f32> V1;bind(V1,A,n);
  dense<f32> V2;bind(V2,B,n);
  f32 S;
  timeval tim;
  gettimeofday(&tim, NULL);
  double t1=tim.tv_sec+(tim.tv_usec/1000000.0);	 
  call(Dot_Product)(V1,V2,S);
  gettimeofday(&tim, NULL);
  double t2=tim.tv_sec+(tim.tv_usec/1000000.0);
  printf("%.6lf seconds elapsed\n", t2-t1);
  return 0;
}
